package puyu.manage.service.utils.except;


import java.util.logging.Level;
import java.util.logging.Logger;

public class GeneralException extends Exception {
    private static final long serialVersionUID = 4997121561818000009L;
    private String code;
    private String message;
    private String systemMessage;

    public GeneralException() {
    }

    public GeneralException(String code) {
        this.code = code;
    }

    public GeneralException(String code, String[] messages, String[] systemMessages) {
        this(code);

        int i;
        for(i = 0; i < messages.length; ++i) {
            this.message = this.message.replaceAll("\\{" + i + "\\}", "[" + messages[i] + "]");
        }

        for(i = 0; i < systemMessages.length; ++i) {
            this.systemMessage = this.systemMessage.replaceAll("\\{" + i + "\\}", "[" + systemMessages[i] + "]");
        }

    }

    public GeneralException(String code, String message, String systemMessage) {
        this.code = code;
        this.message = message;
        this.systemMessage = systemMessage;
    }

    public GeneralException(Throwable targetEx) {
        super(targetEx);
    }

    public String getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.code + "-" + this.message;
    }

    public String getMessageNoCode() {
        return this.message;
    }

    public String getSystemMessage() {
        return this.systemMessage;
    }

    public String toString() {
        return "GeneralException [Code:" + this.code + ", Message:" + this.message + ", SystemMessage:" + this.systemMessage + "]";
    }

    public void setSystemMessage(String systemMessage) {
        this.systemMessage = systemMessage;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void setCode(String code) {
        this.code = code;
    }

    static {
        Logger.getLogger("com.caucho.hessian.server.HessianSkeleton").setLevel(Level.OFF);
    }
}
